package day16;

import java.util.Scanner;

/**
 * 完全数计算
 * https://www.nowcoder.com/practice/7299c12e6abb437c87ad3e712383ff84?tpId=37&&tqId=21279&rp=1&ru=/activity/oj&qru=/ta/huawei/question-ranking
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            int count = 0;
            for (int i = 2; i <= n; i++) {
                int sum = 0;
                for (int j = 2; j <= Math.sqrt(i); j++) {
                    if(i % j == 0) {
                        if(i/j == j) {
                            sum += j;
                        }else {
                            sum += j+i/j;
                        }
                    }
                }
                if(sum + 1 == i) {
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}
